﻿using System;
using System.Web.UI.WebControls;
using BLL;

namespace ProductionAnalysis.Web
{
    public partial class ViewbyProduct_TesterCategory : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                
            }
        }

        protected void Button1_Click(object sender, EventArgs e)
        {
            BindTests();
        }

        private void BindTests()
        {
            DateTime dt1 = DateTime.Parse(this.TextBox2.Text + " 00:00:00");
            DateTime dt2 = DateTime.Parse(this.TextBox3.Text + " 00:00:00");
            string var_UserID = this.TextBox1.Text.Trim();

            Test test = new Test();
            GridView1.DataSource = test.GetTestsbyUserID_DT(var_UserID, dt1, dt2);
            GridView1.DataBind();
            for (int i = 0; i < GridView1.Rows.Count; i++)
            {
                if (GridView1.Rows[i].Cells[7].Text == "Fail")
                    GridView1.Rows[i].Cells[7].ForeColor = System.Drawing.Color.Red;
            }
        }

        protected void GridView1_SelectedIndexChanged(object sender, EventArgs e)
        {
            Session["productSN"] = GridView1.SelectedDataKey["ProductSN"].ToString();
            Session["testTime"] = Convert.ToDateTime(GridView1.SelectedDataKey["TestTime"]);
            Session["ProductTypeID"] = GridView1.SelectedDataKey["ProductTypeID"].ToString();
            Session["UserID"] = GridView1.SelectedDataKey["UserID"].ToString();
            Session["ENAID"] = GridView1.SelectedDataKey["ENAID"].ToString();
            Session["SpecVersion"] = GridView1.SelectedDataKey["SpecVersion"].ToString();
            Session["IsPass"] = GridView1.SelectedDataKey["IsPass"].ToString();

            Response.Redirect("~/ViewTest/ViewYourself/ViewTestItem.aspx");
        }
      
        
        protected void GridView1_PageIndexChanging(object sender, GridViewPageEventArgs e)
        {
            
            this.GridView1.PageIndex = e.NewPageIndex;
            BindTests();
        }
    }
}